package com.example.allinone;

import com.example.allinone.R.string;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

	public void ShowMessage(String string) {
		Toast toast = new Toast(this);
		toast.setText(string);
		toast.show();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		final Resources r = this.getResources();
		final String string = r.getString(R.string.app_name);

		((Button) findViewById(R.id.getResource))
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						Toast.makeText(getApplicationContext(), string,
								Toast.LENGTH_SHORT).show();
					}
				});

		((Button) findViewById(R.id.btnContract))
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						Intent intent = new Intent().setClass(
								MainActivity.this, ContractActivity.class);
						startActivity(intent);
						MainActivity.this.finish();
					}
				});

		((Button) findViewById(R.id.btnMusicServer))
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub

						startService(new Intent(MainActivity.this,
								MusicService.class));
					}
				});

		((Button) findViewById(R.id.btnCloseMusicServer))
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						stopService(new Intent(MainActivity.this,
								MusicService.class));
					}
				});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
